package givenchy

class VipLimitdService {
    def authenticateService
    static transactional = true

    def checkTaskActions(actions,grailsApplication) {
        //println "checkTaskActions=="+grailsApplication.config.grails.vip.great
        def messages = ""
        if(actions){
            def vip1Limited = ['baidu.com','clickad','google.com']
            def vip2Limited = ['clickad']
            // vip为0级或者1级的
            if(authenticateService.userDomain().vip < grailsApplication.config.grails.vip.large){
                messages = checkLimited(actions,vip1Limited)
            }else{
                // vip为2级的
                if(authenticateService.userDomain().vip == grailsApplication.config.grails.vip.large){
                    messages = checkLimited(actions,vip2Limited)
                }
            }
        }

        if(messages){
            return "您的VIP等级为小于2级不能添加关键字【"+messages+"】"
        }else{
            return ""
        }
    }

    def checkLimited(actions,vipLimited){
        def massages = "";
        vipLimited.each{                
            if(actions.indexOf(it) > -1){
                massages = it;
            }
        }
        return massages
    }
}
